import { create } from 'zustand'
import { createJSONStorage, persist } from 'zustand/middleware'
import globalConfig from '@/core/framework/config/globalConfig'
import UpmsMenuAndAuthorityState from '@/core/upms/types/model/dto/UpmsMenuAndAuthorityState'

const useMenuStore = create(
	persist<UpmsMenuAndAuthorityState>(
		(setState, getState) => {
			return { menus: [] } as UpmsMenuAndAuthorityState
		},
		{
			name: `${globalConfig.storageKeyPrefix}.upms.menu`,
			storage: createJSONStorage(() => sessionStorage),
		},
	),
)

export default useMenuStore
